package com.biz.primus.base.elasticsearch.entities;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * 普通商品索引实体
 * <pre>
 *     A类商品文档Entity的Id是VendorId + ProductCode;
 *     B类商品文档Entity的Id是VendorId + depotCode + productCode
 *
 * </pre>
 *
 * @author Nian.Li
 * @ClassName: ProductEntity 
 * @Description: TODO
 * @date 2016年8月23日 下午10:43:44    
 */
@Data
@Document(indexName = "bbc_products", type = "product", refreshInterval = "3s")
public class ProductEntity extends ProductBaseEntity {

    private static final long serialVersionUID = -7654892678154300623L;

    /**
     * ID (业务主键)
     */
    @Id
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed, store = true)
    private String id;

    /**
     * 门店 code
     */
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed, store = true)
    private String depotCode;

    /**
     * 区域库存
     */
    @Field(type = FieldType.Integer, index = FieldIndex.not_analyzed, store = true)
    private Integer stock;

    /**
     * 门店库存 (快喝模式使用)
     */
    @Field(type = FieldType.Integer, index = FieldIndex.not_analyzed, store = true)
    private Integer depotStock;

    /**
     * 区域 ID A类商品使用
     */
    @Field(type = FieldType.String, store = true ,analyzer = "ik", searchAnalyzer = "ik_smart")
    private String geoIds;

    /**
     * 上架状态 总开关
     */
    @Field(type = FieldType.Integer, index = FieldIndex.not_analyzed)
    private Integer saleStatus;

    /**
     * app渠道上架开关
     */
    @Field(type = FieldType.Integer, index = FieldIndex.not_analyzed)
    private Integer webSaleStatus;

    /**
     * 官网渠道上架开关
     */
    @Field(type = FieldType.Integer, index = FieldIndex.not_analyzed)
    private Integer appSaleStatus;

    /**
     * 索引最后更新时间
     */
    @Field(type = FieldType.Long, index = FieldIndex.not_analyzed, store = true)
    private Long lastUpdateTime;

}
